<input id="url_status" type='hidden' value='<?php echo url_for('@get_status') ?>' />
<?php if($oActivPlayer->getTournament()->getStatus()==Tournament::$GAME_STATUS_START): ?>
<h2>Oczekiwanie na rozpoczęcie turnieju <span style="font-weight:normal;"><?php echo $oActivPlayer->getTournament()->getName()?></span></h2>
<div id="waiting" style="margin:50px auto;"><img src="/images/waiting.gif" /></div>
<?php elseif(!$oActMatch): ?>
<h2>Oczekiwanie na rozpoczęcie rundy</h2>
<div id="waiting" style="margin:50px auto;"><img id="img_wait" src="/images/waiting.gif" /><a id="wait_next" href="<?php echo url_for('@user_game') ?>" style="display: none"><div>Rozpocznij rundę</div></a></div>
<input id="randval" type="hidden" value="<?php echo url_for('@round_check?id='.$oActivPlayer->getTournament()->getId()) ?>" />
<?php if(isset($game_list)): ?>
<table class="match_history">
    
    <?php $i=0; foreach($game_list as $oGame): ?>
        <?php if($oGame[7]): ?>
            <tr style="border-bottom:1px solid black">
            <td id="label">Gra <?php echo $i+1 ?>:</td>					
            <td id="empty"></td>
            <?php if($iRealFirstPlayer): ?>
                <?php if($ruleData->getType()==gameRules::$RT_MATRIX): ?>
                    <td id="player_score"><?php echo $ruleData->getRow($oGame[2]) ?> - <?php echo $oGame[3]?></td>
                <?php else: ?>
                    <td id="player_score"><?php echo $oGame[3]?></td>
                <?php endif; ?>
                <td id="player_points">(<?php echo $oGame[1]?>)</td>
                <td id="vs">:</td>
                <?php if($ruleData->getType()==gameRules::$RT_MATRIX): ?>
                    <td id="player_score"><?php echo $ruleData->getCol($oGame[6]) ?> - <?php echo $oGame[6]?></td>
                <?php else: ?>
                    <td id="player_score"><?php echo $oGame[6]?></td>
                <?php endif; ?>
                <td id="player_points">(<?php echo $oGame[5]?>)</td>
            <?php else : ?>
                <?php if($ruleData->getType()==gameRules::$RT_MATRIX): ?>
                    <td id="player_score"><?php echo $ruleData->getCol($oGame[6]) ?> - <?php echo $oGame[6]?></td>
                <?php else: ?>
                    <td id="player_score"><?php echo $oGame[6]?></td>
                <?php endif; ?>
                <td id="player_points">(<?php echo $oGame[5]?>)</td>
                <td id="vs">:</td>
                <?php if($ruleData->getType()==gameRules::$RT_MATRIX): ?>
                    <td id="player_score"><?php echo $ruleData->getRow($oGame[2]) ?> - <?php echo $oGame[3]?></td>
                <?php else: ?>
                    <td id="player_score"><?php echo $oGame[3]?></td>
                <?php endif; ?>                                            
                <td id="player_points">(<?php echo $oGame[1]?>)</td>                                            
            <?php  endif; ?>
            <td id="empty"></td>
            <?php endif; ?>
    </tr>  
    <?php $i++; endforeach; ?>
</table>
 <?php endif ?>
<?php else: ?>
<?php get_partial('game/gameRepresentation'); ?>

<table class="game_table">
	<tr>
		<td colspan="2">			
			
		</td>
	</tr>
	<tr style="height:47px;">
		<td class="game_center" style="font-size:20px;color:#2a2a2a;border-top:1px solid black;">
			<div style="font-size:12pt">
                            <?php if($ruleData->getType()==gameRules::$RT_MATRIX): ?>
				<?php if($iWaitWinId==$oActivPlayer->getId()): ?>
					<span id='user_mess'><img src="/images/iAction.png" /> OCZEKIWANIE NA RUCH GRACZA </span>                                        
                                        <input id="matval" type="hidden" value="1" />
                                <?php else: ?>
                                       <span id='user_mess'> <img src="/images/iAction.png" /> WYKONAJ RUCH </span>
                                        <input id="matval" type="hidden" value="0" />
				<?php endif; ?>
                            <?php else: ?>
                                 <?php $node=$ruleData->getNode($oActGame->getNode());
                                    if($oActGame): ?>
                                    <?php if((!$iFirstplayer && $node->getType()==gameRules::$TN_PLAYER2) ||
                                            ($iFirstplayer && $node->getType()==gameRules::$TN_PLAYER1)): ?>
                                        <span id='user_mess'><img src="/images/iAction.png" /> OCZEKIWANIE NA RUCH GRACZA</span>
                                        <input id="matval" type="hidden" value="1" />
                                    <?php endif; ?>
                                    <?php if(($iFirstplayer && $node->getType()==gameRules::$TN_PLAYER2) ||
                                            (!$iFirstplayer && $node->getType()==gameRules::$TN_PLAYER1)): ?>
                                        <span id='user_mess'><img src="/images/iAction.png" /> WYKONAJ RUCH</span>
                                        <input id="matval" type="hidden" value="0" />
                                    <?php endif; ?>   
                                 <?php endif; ?>
                            <?php endif; ?>        
                            
			</div>
		</td>
		<td>
                    <span id="game_player1" style="font-weight:bold"><?php echo $sf_user->getPlayer()->getNick(); ?><br /><span id="game_role1"><?php echo $ruleData->getPlayerLabel($iFirstplayer); echo '('.($iFirstplayer?2:1).')';  ?></span><br /><?php echo $iTournamentScore[0] ?></span>
			<span id="game_player2"><?php echo $oSecActivPlayer->getPlayer()->getNick(); ?><br /><span id="game_role2"><?php echo $ruleData->getPlayerLabel(!$iFirstplayer); echo '('.(!$iFirstplayer?2:1).')'; ?><br /><?php echo $iTournamentScore[1] ?></span></span>
			<span id="ack_score1"><?php echo $iSecPlayerWins[1]; ?></span> : <span  id="ack_score2"><?php echo $iSecPlayerWins[0]; ?></span><br/>
			<span id="player1_score_points"><?php echo $iSecPlayerScore[0]; ?></span> : <span id="player2_score_points"><?php echo $iSecPlayerScore[1]; ?></span>
                       
        </td>
	</tr
	<tr>
		<td class="game_center gfx" id="game_rules">
			<div id="representation">
                            <?php if($ruleData->getType()==gameRules::$RT_MATRIX): ?> 
                                <?php echo generateMatrixRepresentation($ruleData,($iWaitWinId==$oActivPlayer->getId())?0:($iFirstplayer?(2):(1))); ?>
                            <?php else: ?>
                                <?php 
                                    $tok=$ruleData->getContent();
                                    if($oActGame)
                                    echo generateNode2($tok,0,$oActGame->getNode(),$iFirstplayer+1);
                                ?>
                            <?php endif; ?>
                        </div>
			</td>
		<td class="game_side" style="">
			Informacje o meczu:<br/><br/>
		
			<table class="match_info">
				<tr style="border-bottom:1px solid black" title="HISTORIA TEJ GRY">
					<td id="label">Turniej:</td>
					<td id="value"><?php echo $oTournament->getName() ?></td>
				</tr>
				<tr style="border-bottom:1px solid black" title="HISTORIA TEJ GRY">
					<td id="label">Runda:</td>
					<td id="value"><?php echo $oActMatch->getRoundId() ?></td>
				</tr>
				<tr style="border-bottom:1px solid black" title="HISTORIA TEJ GRY">
					<td id="label">Mecz:</td>
                                        <td id="value"><?php echo $iMatchCount ?></td>
				</tr>
				<tr title="HISTORIA TEJ GRY">
					<td id="label">Gra:</td>
                                        <td id="value"><?php echo $iGameCount ?></td>
				</tr>

			</table>
			
			<!--<div id="waiting"><br /><img src="/images/waiting.gif" /></div>-->
			
			<br/>Historia meczu:<br/><br/>
			
			<table class="match_history">
    
                        <?php $i=0; foreach($game_list as $oGame): ?>
                            <?php if($oGame[7]): ?>
                                <tr style="border-bottom:1px solid black">
                                <td id="label">Gra <?php echo $i+1 ?>:</td>					
                                <td id="empty"></td>
                                <?php if($iRealFirstPlayer): ?>
                                    <?php if($ruleData->getType()==gameRules::$RT_MATRIX): ?>
                                        <td id="player_score"><?php echo $ruleData->getRow($oGame[2]) ?> - <?php echo $oGame[3]?></td>
                                    <?php else: ?>
                                        <td id="player_score"><?php echo $oGame[3]?></td>
                                    <?php endif; ?>
                                    <td id="player_points">(<?php echo $oGame[1]?>)</td>
                                    <td id="vs">:</td>
                                    <?php if($ruleData->getType()==gameRules::$RT_MATRIX): ?>
                                        <td id="player_score"><?php echo $ruleData->getCol($oGame[6]) ?> - <?php echo $oGame[6]?></td>
                                    <?php else: ?>
                                        <td id="player_score"><?php echo $oGame[6]?></td>
                                    <?php endif; ?>
                                    <td id="player_points">(<?php echo $oGame[5]?>)</td>
                                <?php else : ?>
                                    <?php if($ruleData->getType()==gameRules::$RT_MATRIX): ?>
                                        <td id="player_score"><?php echo $ruleData->getCol($oGame[6]) ?> - <?php echo $oGame[6]?></td>
                                    <?php else: ?>
                                        <td id="player_score"><?php echo $oGame[6]?></td>
                                    <?php endif; ?>
                                    <td id="player_points">(<?php echo $oGame[5]?>)</td>
                                    <td id="vs">:</td>
                                    <?php if($ruleData->getType()==gameRules::$RT_MATRIX): ?>
                                        <td id="player_score"><?php echo $ruleData->getRow($oGame[2]) ?> - <?php echo $oGame[3]?></td>
                                    <?php else: ?>
                                        <td id="player_score"><?php echo $oGame[3]?></td>
                                    <?php endif; ?>                                            
                                    <td id="player_points">(<?php echo $oGame[1]?>)</td>                                            
                                <?php  endif; ?>
                                <td id="empty"></td>
                                <?php endif; ?>
                        </tr>  
                        <?php $i++; endforeach; ?>
                    </table>		
		</td>
	</tr>
	<tr style="height:47px;">
		<td class="game_center" style="border-bottom:1px solid black;"></td>
		<td>

			<?php
			
				switch($ruleData->getMatchEndType())
				{
					case gameRules::$EM_GAME;
						echo 'Mecz trwa <span class="end_match_val">'.$ruleData->getMatchEndValue().'</span> gier.';
					break;
					case gameRules::$EM_POINTS_DIF:
						echo 'Mecz trwa do osiągnięcia <span class="end_match_val">'.$ruleData->getMatchEndValue().'</span> punktów przewagi.';
					break;
					case gameRules::$EM_POINTS:
						echo 'Mecz trwa do osiągnięcia <span class="end_match_val">'.$ruleData->getMatchEndValue().'</span> punktów.';
					break;
					case gameRules::$EM_WINS:
						echo 'Mecz trwa do osiągnięcia <span class="end_match_val">'.$ruleData->getMatchEndValue().'</span> zwycięstw.';
					break;
				}
			
			?>
			</td>
	</tr>
</table>

<?php endif ?>

<!--	Wybierz zachowanie:<br/><br/>
	<input id="game_option_url" type="hidden" value="<?php echo url_for('@send_option?id=0') ?>" />
			<div id="game_options" >
				
			</div>
			<a class="game_option" href="<?php echo url_for('@send_option?id=1') ?>">milcz</a><br />
			<a class="game_option" href="<?php echo url_for('@send_option?id=2') ?>">zezwalaj</a>
-->

